<template>
  <div class="login">
    <div class="logincontent">
      <div class="title">后台管理界面</div>
      <el-form @submit.native.prevent="save" class="formline">
        <el-form-item label="用户名:">
          <el-input
            v-model="model.username"
            placeholder="请输入用户名"
          ></el-input>
        </el-form-item>
        <el-form-item label="密码:">
          <el-input
            v-model="model.password"
            placeholder="请输入密码"
          ></el-input>
        </el-form-item>
        <el-form-item style="float:right">
          <el-button type="primary" native-type="submit">确认登陆</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script lang="ts">
import { Vue, Component } from "vue-property-decorator";
import { setcookie } from '@/utils/cookie';
@Component({
  name: "Login"
})
export default class extends Vue {
  public model = {
    username: "",
    password: ""
  };

  private save() {
    if (!this.model.password || !this.model.username) {
      return this.$message.error("请输入用户名或密码");
    }
    setcookie("editor");
    this.$router.push("/home");
  }
}
</script>

<style lang="scss" scoped>
.login {
  width: 100%;
  height: 100vh;
  background: url("../../assets/bgimg.jpg") center center no-repeat;
  background-size: 100% 100%;
  .logincontent {
    position: fixed;
    right: 15%;
    top: 50%;
    padding: 20px;
    width: 450px;
    transform: translateY(-50%);
    box-sizing: border-box;
    .title {
      text-align: center;
      padding: 5px 0px;
      font-size: 15px;
      font-weight: bold;
    }
  }
}
</style>
